Using a numerical integration within fsolve

In this example, we find the chemical potential of a collection of non-interacting identical Bosons.

May 5, 2021

The left-hand side of the equation that we will solve is:

$2\pi^2 n\left(\dfrac{\hbar^2}{2mk_\mathrm{B}T}\right)^{3/2}$

where

$n$ is the particle number density
$m$ is the mass of the particles
$T$ is temperature

On the right-hand side of the equation that we want to solve is the integral:

$\int_0^\infty \dfrac{x^2}{e^{x^2-\eta}-1}\, dx$

where $\eta=\mu/k_\mathrm{B}T$ and $\mu$ is the chemical potential.

We can put the fsolve() statement inside a for loop so that $\eta$ and $\mu/k_\mathrm{B}$ can be found at many different temperatures.

We need to provide fsolve() with initial guesses for each iteration of the loop. The strategy will be to use the $\eta$ solution from the previous iteration as the guess for the current iteration. We then only need to have a reasonable first guess for the first iteration.

We will start the loop at the highest temperature when the chemical potential should have a value that is close to the classical result for an ideal gas. In this case, $\eta=\mu/k_\mathrm{B}T$ is expected to be close to $\ln\left(n/n_\mathrm{Q}\right)$, where:

$n_\mathrm{Q}=\left(\dfrac{mk_\mathrm{B}T}{2\pi\hbar^2}\right)^{3/2}$

Finally, we can also plot the temperature dependence of $\mu$ form out calculation.